package com.mark.web.data.controller.seller;

import com.github.pagehelper.PageInfo;
import com.mark.common.CurrentUser;
import com.mark.common.ServerResponse;
import com.mark.web.data.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description: 卖家处理订单
 * @Author: Mark
 * @CreateDate: 2018/8/14.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@RestController
@RequestMapping("/seller/order")
public class SellerOrderController {
    @Autowired
    private IOrderService iOrderService;


    //1.店家查看接收到的订单
    @PostMapping(value = "list.do")
    public ServerResponse SellerList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iOrderService.getSellerOrderList(CurrentUser.getCurrentUserId(),pageNum,pageSize);
    }

    //2.店家查看订单详情
    @PostMapping(value = "detail.do")
    public ServerResponse SellerDetail(Long orderNo){
        return iOrderService.getOrderDetail(null,orderNo,CurrentUser.getCurrentUserId());
    }

    //3.店家发货
    @PostMapping(value = "send_goods.do")
    public ServerResponse<String> orderSendGoods(Long orderNO){
        return iOrderService.sellerSendGoods(orderNO,CurrentUser.getCurrentUserId());
    }

    //4.店家搜索订单
    @PostMapping(value = "search.do")
    public ServerResponse<PageInfo> orderSearch(Long orderNo, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iOrderService.sellerSearchOrder(orderNo,pageNum,pageSize,CurrentUser.getCurrentUserId());
    }

    //5.店家搜索待发货订单
    @PostMapping(value = "searchPayed.do")
    public ServerResponse<PageInfo> searchOrderPayed(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iOrderService.searchOrderPayed(pageNum,pageSize,CurrentUser.getCurrentUserId());
    }

}
